//
//  MBHTTPNetworking.h
//  Meboo
//
//  Created by kyo on 2023/10/7.
//

#import <Foundation/Foundation.h>


typedef void(^ _Nullable Success)(id _Nullable responseObject);   //成功Block
typedef void(^ _Nullable Failure)(NSError * _Nullable error);     //失败block
typedef void(^ _Nullable Progress)(NSProgress * _Nullable progress); //上传或者下载进度

typedef void(^ _Nullable Unknown)(void);     //未知网络状态的block
typedef void(^ _Nullable Reachable)(void);   //无网络的block
typedef void(^ _Nullable ReachableViaWWAN)(void) ;  // 蜂窝数据网的block
typedef void(^ _Nullable ReachableViaWiFi)(void); //WiFi 网络下的block

@interface MBHTTPNetworking : NSObject



+ (MBHTTPNetworking * _Nullable)sharedInstance;

// 超时时间（默认15秒）
@property (nonatomic, assign) NSTimeInterval timeoutInterval;

/**
 *  网络监测(在什么网络状态)
 *
 *  @param unknown          未知网络
 *  @param reachable        无网络
 *  @param reachableViaWWAN 蜂窝数据网
 *  @param reachableViaWiFi WiFi网络
 */

- (void)networkStatusUnknown:(Unknown)unknown
                  reachable :(Reachable)reachable
            reachableViaWWAN:(ReachableViaWWAN)reachableViaWWAN
            reachableViaWiFi:(ReachableViaWiFi)reachableViaWiFi;



/**
 *  需OAuth认证请求(有加载菊花)
 *
 *  @param urlString  传入url与BaseUrl拼接
 *  @param method     GET 或 POST
 *  @param parameters 参数
 *  @param success    成功返回block
 *  @param failure    失败返回block
 */

- (void)WSAFRequestUrlString:(NSString * _Nullable)urlString
                      method:(NSString * _Nullable)method
                  parameters:(id _Nullable)parameters
                     success:(Success)success
                     failure:(Failure)failure;




//需OAuth认证请求(无加载菊花)
- (void)WSAFNoRequestUrlString:(NSString * _Nullable)urlString
                        method:(NSString * _Nullable)method
                    parameters:(id _Nullable)parameters
                       success:(Success)success
                       failure:(Failure)failure;


//无需认证请求(有加载菊花)
- (void)WSAFNoOAuthUrlString:(NSString * _Nullable)urlString
                      method:(NSString * _Nullable)method
                  parameters:(id _Nullable)parameters
                     success:(Success)success
                     failure:(Failure)failure;

//无需认证请求(无加载菊花)
- (void)WSAFNoOAuthNoUrlString:(NSString * _Nullable)urlString
                        method:(NSString * _Nullable)method
                    parameters:(id _Nullable)parameters
                       success:(Success)success
                       failure:(Failure)failure;



//第一种方法是通过工程中的文件进行上传
- (void)WSUpLoadImageData:(NSData * _Nullable)imageData
                urlString:(NSString * _Nullable)urlString
               parameters:(id _Nullable)parameters
                 progress:(Progress)progress
                  success:(Success)success
                  failure:(Failure)failure;


//第二种是通过URL来获取路径，进入沙盒或者系统相册等等
- (void)WSUpLoadImageUrl:(NSString * _Nullable)imageUrl
               urlString:(NSString * _Nullable)urlString
              parameters:(id _Nullable)parameters
                progress:(Progress)progress
                 success:(Success)success
                 failure:(Failure)failure;

/**
 *  上传图片
 *
 *  @param imageArray   上传的图片数组
 *  @parm width      图片要被压缩到的宽度
 *  @param urlString    上传的url
 *  @param successBlock 上传成功的回调
 *  @param failureBlock 上传失败的回调
 */

- (void)uploadImageWithParms:(NSDictionary * _Nonnull )parms
              withImageArray:(NSArray * _Nonnull)imageArray
             withtargetWidth:(CGFloat)width
               withUrlString:(NSString * _Nonnull)urlString
            withSuccessBlock:(Success)successBlock
             withFailurBlock:(Failure)failureBlock;

/**
 *  上传头像
 */
- (void)upheaderImageWithParms:(NSDictionary * _Nonnull )parms
                     withImage:(UIImage * _Nonnull)image
               withtargetWidth:(CGFloat )width
                 withUrlString:(NSString * _Nonnull)urlString
              withSuccessBlock:(Success)successBlock
               withFailurBlock:(Failure)failureBlock;


#pragma mark - 后台统计
- (void)WSAFNoOAuthIdfaWithmethod:(NSString * _Nullable)method
                       parameters:(id _Nullable)parameters
                          success:(Success)success
                          failure:(Failure)failure;

#pragma mark - 无需认证请求(有加载菊花)-----加上菊花
- (void)WSAFNHudUrlString:(NSString * _Nullable)urlString
                      method:(NSString * _Nullable)method
                  parameters:(id _Nullable)parameters
                     success:(Success)success
                  failure:(Failure)failure;
@end
